
use "apr replication study 1.dta", replace

reg restrict to fraud age age1 white1 black1 hisp1 female1 educ1 inc1  if pid3==1

coefplot, drop(_cons) ///
aspect(1) ///
graphregion(fcolor(white)) ///
xlabel(, notick) ///
ylabel(,labsize(small) notick) ///
xline(0, lwidth(medium) lcolor(black) lpattern(solid)) ///
order (to fraud tocond fcond condto condfr) ///
coeflabels( ///
to = "Turnout Helps Dems" ///
fraud = "Lots of Fraud in 2020" ///
age1= "Age" ///
white1 = "White" ///
black1 = "Black" ///
hisp1 = "Hispanic" ///
female1 = "Sex" ///
educ1 = "Education" ///
inc1 = "Income") ///
title("A. Democrats", ///
span size(*.9) linegap(1.5) margin(medium)) ///


graph save figure2a, replace


reg restrict to fraud to fraud age1 white1 black1 hisp1 female1 educ1 inc1 if pid3==3

coefplot, drop(_cons) ///
aspect(1) ///
graphregion(fcolor(white)) ///
xlabel(, notick) ///
ylabel(,labsize(small) notick) ///
xline(0, lwidth(medium) lcolor(black) lpattern(solid)) ///
order (to fraud tocond fcond condto condfr) ///
coeflabels( ///
to = "Turnout Helps Dems" ///
fraud = "Lots of Fraud in 2020" ///
age1= "Age" ///
white1 = "White" ///
black1 = "Black" ///
hisp1 = "Hispanic" ///
female1 = "Sex" ///
educ1 = "Education" ///
inc1 = "Income") ///
title("B. Republicans", ///
span size(*.9) linegap(1.5) margin(medium)) ///

graph save figure2b, replace

gr combine figure2a.gph figure2b.gph, col(1) iscale(1) ///
graphregion(fcolor(white))

graph save figure2ab,replace

graph bar to1 to2 to3, over(pid3new) aspect(1) graphregion(fcolor(white))

*changed indep bar color to grayscale6 and changed labels in graph editor to match other graph

sem (restrict <- fraud demnoindep) (fraud <- demnoindep), standard
estat teffects,standard

 sem (demnoindep -> fraud, ) (demnoindep -> restrict, ) (fraud -> restrict, ), nocapslatent

*the indirect path through fraud adds to the total effect of PID
*use strutural equation builder point and click to make path diagram
fin


